import { rcaNumberFormat } from './common.js'
import { dateFormat } from '@/util/date';
import { commonTableOption } from './common.js'

function noDiff (val) {
  return val === undefined || val === 0
}
export const startDate = dateFormat(new Date(), 'yyyy-MM-') + '01';
export const endDate = dateFormat(new Date(), 'yyyy-MM-dd');
export const tableOption = {
  ...commonTableOption,
  page: false,
  selection: true,
  showSummary: true,
  height: '400px',
  // selectable: (row, index) => {
  //   return (
  //     row.confirmStatus === '0'
  //     // noDiff(row.diffAlipyAmount) &&
  //     // noDiff(row.diffWechartAmount) &&
  //     // noDiff(row.diffUnionpayBankAmount)
  //   );
  // },
  column: [{
    type: 'date',
    width: "100px",
    label: '交易日期',
    prop: 'tradeDate',
    searchSpan: 12,
    searchRange: true,
    search: true,
    searchValue: [startDate, endDate],      // 这是我获取的默认的显示日期，我这里是['2020-08-04', '2020-09-22']
    format: 'yyyy-MM-dd',                  // 这是组件展示的日期格式
    valueFormat: 'yyyy-MM-dd',
  }, {
    label: '支付宝、微信、银联交易统计表',
    children: [{
      label: '支付宝',
      children: [{
        type: 'input',
        showSummary: true,
        precision: 2,
        formatter: (row, value, label, column) => {
          return rcaNumberFormat(value, true)
        },
        width: "120px",
        label: '支付宝交易金额',
        prop: 'alipayTradeAmount'
      }, {
        type: 'input',
        showSummary: true,
        precision: 2,
        formatter: (row, value, label, column) => {
          return rcaNumberFormat(value, true)
        },
        width: "150px",
        label: '支付宝手续费金额',
        prop: 'alipayTradeServiceAmount'
      }, {
        type: 'input',
        showSummary: true,
        precision: 2,
        formatter: (row, value, label, column) => {
          return rcaNumberFormat(value, true)
        },
         width: "150px",
        label: '支付宝银行存款金额',
        prop: 'alipayTradeBankAmount'
      }

      ]
    }, {
      label: '微信',
      children: [{
        type: 'input',
        showSummary: true,
        precision: 2,
        formatter: (row, value, label, column) => {
          return rcaNumberFormat(value, true)
        },
        width: "120px",
        label: '微信交易金额',
        prop: 'wechartTradeAmount'
      }, {
        type: 'input',
        showSummary: true,
        precision: 2,
        formatter: (row, value, label, column) => {
          return rcaNumberFormat(value, true)
        },
         width: "150px",
        label: '微信手续费金额',
        prop: 'wechartTradeServiceAmount'
      }, {
        type: 'input',
        showSummary: true,
        precision: 2,
        formatter: (row, value, label, column) => {
          return rcaNumberFormat(value, true)
        },
         width: "150px",
        label: '微信银行存款金额',
        prop: 'wechartTradeBankAmount'
      },]
    }, {
      label: '银联',
      children: [{
        type: 'input',
        showSummary: true,
        precision: 2,
        formatter: (row, value, label, column) => {
          return rcaNumberFormat(value, true)
        },
        width: "120px",
        label: '银联交易金额',
        prop: 'unionpayTradeAmount'
      }, {
        type: 'input',
        showSummary: true,
        precision: 2,
        formatter: (row, value, label, column) => {
          return rcaNumberFormat(value, true)
        },
         width: "150px",
        label: '银联交易手续费金额',
        prop: 'unionpayBankSpontaneousCode'
      }, {
        type: 'input',
        showSummary: true,
        precision: 2,
        formatter: (row, value, label, column) => {
          return rcaNumberFormat(value, true)
        },
         width: "150px",
        label: '银联银行存款金额',
        prop: 'unionpayBankTradeBankAmount'
      },]
    }]

  }, {
    label: '应急及互联互通交易统计表',
    children: [{
      label: '支付宝',
      children: [{
        type: 'input',
        showSummary: true,
        precision: 2,
        formatter: (row, value, label, column) => {
          return rcaNumberFormat(value, true)
        },
         width: "120px",
        label: '交易金额',
        prop: 'alipayConnectivityAmount'
      }, {
        type: 'input',
        showSummary: true,
        precision: 2,
        formatter: (row, value, label, column) => {
          return rcaNumberFormat(value, true)
        },
         width: "120px",
        label: '手续费金额',
        prop: 'alipayConnectivityServiceAmount'
      }, {
        type: 'input',
        showSummary: true,
        precision: 2,
        formatter: (row, value, label, column) => {
          return rcaNumberFormat(value, true)
        },
         width: "120px",
        label: '银行存款金额',
        prop: 'alipayTradeBankAmount'
      }

      ]
    }, {
      label: '微信',
      children: [{
        type: 'input',
        showSummary: true,
        precision: 2,
        formatter: (row, value, label, column) => {
          return rcaNumberFormat(value, true)
        },
         width: "120px",
        label: '交易金额',
        prop: 'wechartConnectivityAmount'
      }, {
        type: 'input',
        showSummary: true,
        precision: 2,
        formatter: (row, value, label, column) => {
          return rcaNumberFormat(value, true)
        },
         width: "120px",
        label: '手续费金额',
        prop: 'wechartConnectivityServiceAmount'
      }, {
        type: 'input',
        showSummary: true,
        precision: 2,
        formatter: (row, value, label, column) => {
          return rcaNumberFormat(value, true)
        },
         width: "120px",
        label: '银行存款金额',
        prop: 'wechartConnectivityBankAmount'
      },]
    }]

  }, {
    label: '人脸差异（交易-银行）',
    children: [{
      type: 'input',
      showSummary: true,
      precision: 2,
      formatter: (row, value, label, column) => {
        return rcaNumberFormat(value, true)
      },
       width: "150px",
      label: '支付宝（交易-银行）',
      prop: 'diffAlipyAmount',
      slot: true
    }, {
      type: 'input',
      showSummary: true,
      precision: 2,
      formatter: (row, value, label, column) => {
        return rcaNumberFormat(value, true)
      },
       width: "150px",
      label: '微信（交易-银行）',
      prop: 'diffWechartAmount',
      slot: true
    }, {
      type: 'input',
      showSummary: true,
      precision: 2,
      formatter: (row, value, label, column) => {
        return rcaNumberFormat(value, true)
      },
       width: "150px",
      label: '银联（交易-银行）',
      prop: 'diffUnionpayBankAmount',
      slot: true
    },]
  }, {
    label: '互联互通差异（交易-银行）',
    children: [{
      type: 'input',
      showSummary: true,
      precision: 2,
      formatter: (row, value, label, column) => {
        return rcaNumberFormat(value, true)
      },
       width: "150px",
      label: '支付宝（交易-银行）',
      prop: 'diffAlipyConnectivityAmount',
      slot: true
    }, {
      type: 'input',
      showSummary: true,
      precision: 2,
      formatter: (row, value, label, column) => {
        return rcaNumberFormat(value, true)
      },
       width: "150px",
      label: '微信（交易-银行）',
      prop: 'diffWechartConnectivityAmount',
      slot: true
    }]
  }, {
    type: 'select',
    label: '状态',
    prop: 'confirmStatus',
    search: true,
    dicData: [
      {
        label: '已确认',
        value: '1'
      }, {
        label: '未确认',
        value: '0'
      }
    ]
  }]
}
